import { Table } from "antd";
import "./index.scss";
import { useState, useEffect } from "react";
import type { ColumnsType } from "antd/es/table";
import { useNavigate } from "react-router-dom";
import "react-quill/dist/quill.snow.css";
import http from "../../../../utils/http";

const ApproveAlerts = () => {
  //返回
  const navigate = useNavigate();
  const fh = (link: string) => {
    navigate("/zhome" + link);
  };

  //表内容
  const [data, setData] = useState([]);
  const columns: ColumnsType<DataType> = [
    {
      title: "办学资金",
      dataIndex: "amoney",
      key: "amoney",
    },
    {
      title: "老师资质",
      dataIndex: "ateacher",
      key: "ateacher",
    },
    {
      title: "培训课程",
      dataIndex: "acourse",
      key: "acourse",
    },
  ];

  // 表格信息
  interface DataType {
    key: string;
    amoney: String;
    ateacher: String;
    acourse: String;
  }

  // 渲染数据
  const getData = () => {
    http({
      url: "/getApprove",
    }).then((res) => {
      console.log("所有数据", res);
      let _data = res.data.map((v: { id: number }) => {
        return { ...v, key: v.id };
      });
      setData(_data);
    });
  };
  useEffect(() => {
    getData();
  }, []);

  return (
    <div className="ApproveAlerts">
      <div className="top">
        <div className="top-l">
          <p
            className="title"
            onClick={() => {
              fh("/setUp");
            }}
          >
            设置
          </p>
          <div>&gt;</div>
          <p className="detail">审核条件预警配置</p>
        </div>
      </div>

      <div className="hr"></div>

      <div className="jj">
        <p>审核时应当符合以下条件，有助于判断</p>

        <Table
          columns={columns}
          dataSource={data}
          bordered={true}
          pagination={false}
          style={{
            paddingTop: "20px",
          }}
        />
      </div>
    </div>
  );
};
export default ApproveAlerts;
